var Web3 = require('web3');
const comtrollerABI = require('./abi/ERC20ABI.json'); // abi信息


const secretIndex = process.argv.indexOf('--secret');
//secretValue 表示私钥
let secretValue;

if (secretIndex > -1) {
    // Retrieve the value after --custom
    secretValue = process.argv[secretIndex + 1];
}

const secret = (secretValue || 'Default');

const tokenIndex = process.argv.indexOf('--tokenAddress');
let tokenValue;

if (tokenIndex > -1) {
    // Retrieve the value after --custom
    tokenValue = process.argv[tokenIndex + 1];
}
const tokenAddress = (tokenValue || 'Default');


const approveIndex = process.argv.indexOf('--approveAddress');
let approveValue;

if (approveIndex > -1) {
    // Retrieve the value after --custom
    approveValue = process.argv[approveIndex + 1];
}

var web3 = new Web3(new Web3.providers.HttpProvider('https://bsc-dataseed.binance.org/'));
//var web3 = new Web3(new Web3.providers.HttpProvider('https://http-testnet.hecochain.com'));
var wallet = web3.eth.accounts.privateKeyToAccount(secret);
web3.eth.accounts.wallet.add(secret);
let tokenContract = new web3.eth.Contract(comtrollerABI,tokenAddress);

web3.eth.getGasPrice()
    .then(console.log);
let amount = web3.utils.toWei('1', 'ether');
let tx = tokenContract.methods.approve(approveValue,amount).send({from:wallet.address,gasPrice:55000000000,gasLimit:5500000000,gas:21770});



